import request from '../utils/request' //内置声明文件的的module不能使用路径别名

interface HttpResponse {
  // 接口响应通过格式
  info?: string
  status?: number
  data?: {
    [key: string]: any
  }
}

// 下拉区域
export function getRegionById (data:object) {
  return request({
    url: '/statistics/2.0.1/getRegionById',
    method: 'post',
    data,
  })
}
/**
 * 预警列表
 */
export function anomalyAlarmList (urlBase:string,archId?:string) {
  let url = "", method=''
  if (urlBase==='/wy'){ //物业报警接口
    if (archId == undefined) {
      url = `/message/2.0/queryCount`
    } else {
      url = `/message/2.0/queryCount?archId=${archId}`
    }
    method = 'get'
  }
  else {//消防报警接口
    url = '/wy/monitoring/2.0.1/anomalyAlarmList'
    method='post'
  }
  // @ts-ignore
  return request({
    url: url,
    method: method,
  })
}
// 预警详情
export function exceptionDetail (urlBase:string,data:object) {
  let url = ""
  if (urlBase === '/wy') { //物业报警接口
    url = `/statistics/2.0.1/exceptionDetail`
  }
  else {//消防报警接口
    url = '/user/2.0.1/exceptionDetail'
  }
  return request({
    url: url,
    method: 'post',
    data,
  })
}
// 数量统计
export function getTotal(data?: object): Promise<HttpResponse> {
  return request({
    url: '/wy/statistics/2.0.1/allStatisticsNumber',
    method: 'post',
    data,
  })
}

// 地级市信息
export function getMonitorTab (data:object) {
  return request({
    url: '/statistics/2.0.1/prefectureLevelList',
    method: 'post',
    data,
  })
}

//设备数据比值
export function getDevice (data:object) {
  return request({
    url: '/statistics/2.0.1/deviceStatusStatistics',
    method: 'post',
    data,
  })
}

//设备种类
export function getProductCount (data:object) {
  return request({
    url: '/statistics/2.0.1/deviceProductCount',
    method: 'post',
    data,
  })
}

//建筑新增趋势
export function newArchTrend (data:object) {
  return request({
    url: '/statistics/2.0.1/newArchTrend',
    method: 'post',
    data,
  })
}

//面积新增趋势
export function areaGrowthTrend (data:object) {
  return request({
    url: '/statistics/2.0.1/areaGrowthTrend',
    method: 'post',
    data,
  })
} newDeviceTrend

//设备新增趋势
export function newDeviceTrend (data:object) {
  return request({
    url: '/statistics/2.0.1/newDeviceTrend',
    method: 'post',
    data,
  })
}
//物业新增趋势
export function newSubjectTrend (data:object) {
  return request({
    url: '/statistics/2.0.1/newSubjectTrend',
    method: 'post',
    data,
  })
}

//概览详情
export function overviewDetail (urlBase:string,data:object) {
  let url = ""
  if (urlBase === '/wy') { //物业报警接口
    url = `/statistics/2.0.1/overviewDetail`
  }
  else {//消防报警接口
    url = '/user/2.0.1/overviewDetail'
  }
  return request({
    url: url,
    method: 'post',
    data,
  })
}

//入驻单位分布
export function joinUnitDistribution (urlBase:string,data:object) {
  let url = ""
  if (urlBase === '/wy') { //物业报警接口
    url = `/statistics/2.0.1/joinUnitDistribution`
  }
  else {//消防报警接口
    url = '/user/2.0.1/joinUnitDistribution'
  }
  return request({
    url: url,
    method: 'post',
    data,
  })
}

//数据比值详情
export function deviceRatioDetail (data:object) {
  return request({
    url: '/statistics/2.0.1/deviceRatioDetail',
    method: 'post',
    data,
  })
}

//地图中心数据
export function distributeList (data:object) {
  return request({
    url: '/statistics/2.0.1/distributeList',
    method: 'post',
    data,
  })
}